package br.mikhas.task.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import br.mikhas.util.ExceptionUtils;

public final class DateUtils {
	private DateUtils() {
	}

	public static Date createDate(String date) {
		try {
			return new SimpleDateFormat("yyyyMMdd").parse(date);
		} catch (ParseException e) {
			throw ExceptionUtils.wrapChecked(e);
		}
	}

	public static void main(String[] args) {
		long time = System.currentTimeMillis();
		long cutoff = 1000 * 60 * 60 * 24;
		long truncated = time / cutoff;
		truncated *= cutoff;
		System.out.println(new Date(truncated));
	}
}
